package com.company.project.service.impl;

import com.company.project.dao.PeriodicalsCategoryRMapper;
import com.company.project.model.PeriodicalsCategoryR;
import com.company.project.model.PeriodicalsDbR;
import com.company.project.service.PeriodicalsCategoryRService;
import com.company.project.core.AbstractService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.List;


/**
 * Created by CodeGenerator on 2018/10/08.
 */
@Service
@Transactional
public class PeriodicalsCategoryRServiceImpl extends AbstractService<PeriodicalsCategoryR> implements PeriodicalsCategoryRService {
    @Resource
    private PeriodicalsCategoryRMapper periodicalsCategoryRMapper;

    //后台设置期刊专业
    @Override
    public Integer adminAddPeriodicalsCategoryR(List<PeriodicalsCategoryR> periodicalsCategoryR) {
        return periodicalsCategoryRMapper.insertList(periodicalsCategoryR);
    }

    //后台修改期刊专业
    @Override
    public Integer adminUpdatePeriodicalsCategoryR(PeriodicalsCategoryR periodicalsCategoryR) {
        Example example = new Example(PeriodicalsCategoryR.class);
        Example.Criteria criteria= example.createCriteria();
        criteria.andEqualTo("cid",periodicalsCategoryR.getOldCid());
        criteria.andEqualTo("pid",periodicalsCategoryR.getPid());
        return periodicalsCategoryRMapper.updateByConditionSelective(periodicalsCategoryR,example);
    }

    //后台根据pid删除
    @Override
    public Integer adminDelectByPid(Integer pid) {
        return periodicalsCategoryRMapper.adminDelectByPid(pid);
    }
}
